package com.visualization.server.service.impl;


import com.visualization.server.entities.User;
import com.visualization.server.mapper.UserMapper;
import com.visualization.server.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public Integer addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public Integer deleteUser(User user) {
        int num = -1;
        User userById = userMapper.getUserById(user.getId());
        if (userById!=null){
            num = userMapper.deleteUser(user);
        }
        return num;
    }

    @Override
    public Integer updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public User getUserById(Integer id) {
        return userMapper.getUserById(id);
    }

    @Override
    public List<User> getUserList() {
        return userMapper.getUserList();
    }
}
